#ifndef _LIBGFW
#define _LIBGFW

#include <inttypes.h>
#include <stdbool.h>
#include "kv.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _gfw_request {
    char *url;
    char *method;
    char *http_version;
    kv_pair *header;
    kv_pair *cookie;
    kv_pair *post_data;
}gfw_request;

typedef struct _gfw_cookie {
    char *key;
    char *value;
    char *expires;
    char *domain;
    char *path;
    struct _gfw_cookie *next;
} gfw_cookie;

typedef struct _gfw_response {
    char *version;
    char *status;
    char *body;
    kv_pair *header;
    gfw_cookie *cookie;
} gfw_response;

gfw_request *gfw_init();
bool gfw_set_url(gfw_request *gr,char *url);
bool gfw_set_method(gfw_request *gr,char *method);
bool gfw_add_header(gfw_request *gr,char *key,char *value);
bool gfw_add_unique_header(gfw_request *gr,char *key,char *value);
bool gfw_add_cookie(gfw_request *gr,char *key,char *value);
bool gfw_add_post_data(gfw_request *gr,char *key,char *value);
bool gfw_remove_header(gfw_request *gr,char *key);
gfw_response *gfw_send(gfw_request *gr);
bool gfw_free(gfw_request *gr);

gfw_response *gfw_response_parse(const char *res_str);
bool gfw_response_free(gfw_response *gres);
#ifdef __cplusplus
}
#endif

#endif/*_LIBGFW*/
